<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .title{
            color: red;
        }
    </style>
</head>
<body>
    最基础react应用
    <!-- 2. 根节点 -->
    <div id="app"></div>
    <!-- 1. 引入react依赖 -->
    <script type="text/javascript" src="../js/react.development.js"></script>
    <!-- 用于react操作dom -->
    <script type="text/javascript" src="../js/react-dom.development.js"></script>
    <!-- babel将jsx转为js -->
    <script type="text/javascript" src="../js/babel.min.js"></script>
    <!-- 3. type需声明使用babel翻译 -->
    <script type="text/babel">
    //  创建虚拟dom-jsx 本质就是为了方便创建dom的语法糖
    const id = 'myId'
    const vDom = (
        <div>
            <h1 id={id} className="title">
                <span style={{color: 'yellow', fontSize: '24px'}}>hello world</span>
            </h1>
            <input type="text" />
        </div>
    )
    // 转为js： React.createElement('h1', {id: 'title'}, React.createElement('span', {}, 'hello world')) ，

    // jsx练习
    const data = ['angular', 'react', 'vue'];
    const vDom1 = (
        <ul>
            {data.map(i => <li>i</li>)}
        </ul>
    )
    // 渲染dom
    ReactDOM.render(vDom1, document.getElementById('app'))
    console.log('虚拟dom', vDom);
    debugger
    console.log(typeof vDom)
    console.log(vDom instanceof Object)
    </script>

</body>
</html>